﻿Imports System.Data
Imports System.Data.Odbc
Imports WSEntidades
Imports Utilerias
Imports Npgsql
Imports MySql.Data.MySqlClient
Public Class VendedoresFact
    Public Shared Function Build(ByVal dr As MySqlDataReader) As VendedoresBE
        Return buildInternal(dr.Item("IdVendedor"),
                             dr.Item("Clave"),
                             dr.Item("Nombre"),
                             dr.Item("Porc"),
                             dr.Item("Status"))
    End Function

    Public Shared Function buildInternal(ByVal idVendedor As Object, ByVal clave As Object,
                                         ByVal nombre As Object, ByVal porc As Object, ByVal status As Object) As VendedoresBE
        Dim tmpVendedores As VendedoresBE = New VendedoresBE()
        Try
            With tmpVendedores
                '.IdEmpresa = convertDTFromDb.convertInt32(idEmpresa)
                .IdVendedor = convertDTFromDb.convertInt32(idVendedor)
                .Clave = convertDTFromDb.ConvertString(clave)
                .Nombre = convertDTFromDb.ConvertString(nombre)
                .PorcComision = convertDTFromDb.ConvertDecimal(porc)
                Select Case convertDTFromDb.ConvertString(status)
                    Case "A"
                        .Status = VendedoresBE.EstatusVendedor.Activo
                    Case "I"
                        .Status = VendedoresBE.EstatusVendedor.Inactivo
                    Case Else
                        .Status = VendedoresBE.EstatusVendedor.Inactivo
                End Select
            End With
            Return tmpVendedores
        Catch ex As Exception
            Throw
        Finally
            tmpVendedores = Nothing
        End Try
    End Function
End Class
